  <table class="table table-striped">
    <thead>
      <tr>
        <th colspan="4"><?php printf($this->_lang['stats_top_referrers'], $toplimit); ?></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class='row3'><b><?php echo $this->_lang['rank']; ?></b></td>
        <td class='row3' width="25%"><b><?php echo $this->_lang['referrer']; ?></b></td>
        <td class='row3' width="25%" colspan="2"><b><?php echo $this->_lang['page_impressions']; ?></b></td>
      </tr>
  <?php
  $sql = "SELECT COUNT(t1.document) AS hits, t2.data AS referer FROM ".$this->db."log_access AS t1, ".$this->db."log_referers AS t2 WHERE t1.referer = t2.id AND t1.timestamp > $startdate AND t1.timestamp < $enddate AND t2.data!='Unknown' AND t2.data!='Internal' GROUP BY referer ORDER BY hits DESC LIMIT $toplimit";
  $rs = $this->dbQuery($sql);
  $actualRows = $this->recordCount($rs);
  for($i=0;$i<$actualRows; $i++) {
    $tmp = $this->fetchRow($rs);
    $referer = $tmp['referer'];
    $refererString = $referer!='Internal' && $referer!='Unknown' ? "<a href='$referer' target='_blank'>$referer</a>" : "-";
  ?>
      <tr>
        <td class='row3' style="width:12.5%;"><?php echo $i+1; ?></td>
        <td class='row1'><?php echo $refererString; ?></td>
        <td class='row1' style="width:12.5%;"><?php echo $tmp['hits']; ?></td>
        <td class='row1' style="width:12.5%;"><?php echo $tmp['hits']==0 ? "-" : number_format(($tmp['hits']/$pitotal)*100, 1)." %"; ?></td>
      </tr>
  <?php
  }
  if($actualRows==0) {
  ?>
      <tr>
        <td class='row1' colspan="4"><?php echo $this->_lang['no_results']; ?></td>
      </tr>
  <?php
  }
  ?>
    </tbody>
  </table>